package cn.com.api.entity;

import cn.com.api.entity.base.U_discoverBase;

import java.io.Serializable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

// U_discover Entity

/// <summary>
/// Datetime: 2017/2/4 9:24:26		
/// the entity of table U_discover.
/// </summary>

public class ApiU_discover extends U_discoverBase implements Serializable {

	public int getStatus() {
		if (this.getIs_delete() == 1) {
			return 0; // 已删除
		} else if (this.getIs_cancel() == 1) {
			return 6; // 已取消
		}				
		else {
			if (this.getIs_verify() == 0) {
				return 1; // 待审核
			} else if (this.getIs_verify() == 1) {
								
				try {
					 if (this.getType() == 1) {
						return 2; // 已审核
					 }

					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					Date beginTime = null;
					if (this.getBegin_time().length() == 10) {
						sdf = new SimpleDateFormat("yyyy-MM-dd");
						beginTime = sdf.parse(this.getBegin_time());
					} else if (this.getBegin_time().length() == 15) {
						sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
						beginTime = sdf.parse(this.getBegin_time());
					} else {
						beginTime = sdf.parse(this.getBegin_time());
					}
					Date now = Calendar.getInstance().getTime();
					sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					Date endTime = null;
					if (this.getEnd_time().length() == 10) {
						sdf = new SimpleDateFormat("yyyy-MM-dd");
						endTime = sdf.parse(this.getEnd_time());
					}
					else if (this.getEnd_time().length() == 15) {
						sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
						endTime = sdf.parse(this.getEnd_time());
					} 
					else {
						endTime = sdf.parse(this.getEnd_time());
					}
					if (now.compareTo(beginTime) >= 0) {
						if (now.compareTo(endTime) <= 0) {
							return 4; // 已开始
						} else {
							return 5; // 已结束
						}
					} else {
						return 2; // 已审核
					}
					
				} catch (Exception ex) {
					ex.printStackTrace();
					return 2;
				}
			} else if (this.getIs_verify() == 2) {
				return 3;// 已驳回
			}
		}

		return 1; // 待审核
	}

	private int is_favorite = 0;

	private String city = "";

	private Integer share_count = 0;

	private int zan_count = 0;

	private int comment_count = 0;
	
	private int favorite_count = 0;
	
	private int is_zan = 0;
	
	//活动类型
	private String cate_type = "";
	
	//用户电话
	private String c_mob= "";
	
	
	public String getC_mob() {
		return c_mob;
	}

	public void setC_mob(String c_mob) {
		this.c_mob = c_mob;
	}

	
	
	public String getCate_type() {
		return cate_type;
	}

	public void setCate_type(String cate_type) {
		this.cate_type = cate_type;
	}

	//报名状态,0:未报名，1：已报名
	private int is_enroll = 0;
	


	public int getIs_enroll() {
		return is_enroll;
	}

	public void setIs_enroll(int is_enroll) {
		this.is_enroll = is_enroll;
	}

	public int getComment_count() {
		return comment_count;
	}

	public void setComment_count(int comment_count) {
		this.comment_count = comment_count;
	}


	public Integer getShare_count() {
		return share_count;
	}

	public void setShare_count(Integer share_count) {
		this.share_count = share_count;
	}

	public int getZan_count() {
		return zan_count;
	}

	public void setZan_count(int zan_count) {
		this.zan_count = zan_count;
	}

	public int getFavorite_count() {
		return favorite_count;
	}

	public void setFavorite_count(int favorite_count) {
		this.favorite_count = favorite_count;
	}

	public int getIs_zan() {
		return is_zan;
	}

	public void setIs_zan(int is_zan) {
		this.is_zan = is_zan;
	}

	public int getIs_favorite() {
		return is_favorite;
	}

	public void setIs_favorite(int is_favorite) {
		this.is_favorite = is_favorite;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}
	
	//列表展示价格
	private BigDecimal show_price = BigDecimal.ZERO;
	
	
	public BigDecimal getShow_price() {
		return show_price;
	}

	public void setShow_price(BigDecimal show_price) {
		this.show_price = show_price;
	}


}
